//
//  Button2ViewController.m
//  TrueLove
//
//  Created by han on 15-1-30.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "Button2ViewController.h"
#import "AFHTTPRequestOperationManager.h"
#import "DownStrategy.h"
@interface Button2ViewController ()
@property (nonatomic, retain) NSMutableDictionary *dic;
@property (nonatomic, retain) UIScrollView *scrollView;
@end

@implementation Button2ViewController
- (void)dealloc
{
    [_dic release];
    [_scrollView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self showScrollView];
    NSString *str = @"http://hunliji.com/v1/api/app/wedding_raiders/3.json";
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    [manger GET:str parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        self.dic = [NSMutableDictionary dictionary];
        self.dic = responseObject;
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 10, self.view.bounds.size.width, 50)];
        titleLabel.text = [self.dic objectForKey:@"title"];
        titleLabel.numberOfLines = 2;
        titleLabel.font = [UIFont boldSystemFontOfSize:24];
        [self.scrollView addSubview:titleLabel];
        [titleLabel release];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 60, self.view.bounds.size.width, 800)];
        label.text = [self.dic objectForKey:@"content"];
        label.numberOfLines = 0;
        NSLog(@"%@", label.text);
        [self.scrollView addSubview:label];
        [label release];

        
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}
- (void)showScrollView
{
    self.scrollView = [[[UIScrollView alloc] initWithFrame:self.view.bounds] autorelease];
    self.scrollView.contentSize = CGSizeMake(0, 800);
    
    [self.view addSubview:self.scrollView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
